import 'package:flutter/material.dart';
import 'package:get/get.dart';
// import 'package:pet/app/notification_controller.dart';
import 'package:pet/app/storage/token.dart';
import 'package:pet/app/websocket_controller.dart';
import 'package:pet/env.dart';

import 'app/routes/app_pages.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:get_storage/get_storage.dart';
import 'package:awesome_notifications/awesome_notifications.dart';
import 'dart:io';

void main() {
  GetStorage.init();
  Get.put<TokenStorage>(TokenStorage());
  Get.put<WebsocketController>(WebsocketController());

  if (Platform.isAndroid) {
    AwesomeNotifications().initialize(
      // set the icon to null if you want to use the default app icon
      'resource://drawable/logo',
      [
        NotificationChannel(
          channelKey: 'basic_channel',
          channelName: 'Basic notifications',
          channelDescription: '客户消息通知',
          defaultColor: Color(0xFF9D50DD),
          ledColor: Colors.white,
          // 设置小图标
        )
      ],
      debug: true,
    );
    AwesomeNotifications().isNotificationAllowed().then((isAllowed) {
      if (!isAllowed) {
        // Insert here your friendly dialog box before call the request method
        // This is very important to not harm the user experience
        AwesomeNotifications().requestPermissionToSendNotifications();
      }
    });
  }

  initializeDateFormatting().then((_) => runApp(const MyApp()));
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: '宠宝客服',
      debugShowCheckedModeBanner: false,
      initialRoute: AppPages.INITIAL,
      getPages: AppPages.routes,
    );
  }
}
